<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<title>无标题文档</title>
	<link href="/static/css/default.css" rel="stylesheet" type="text/css">
	<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id=link'>

</head>

<body style="overflow:hidden; padding:10px;">
	<form>
		<table class="formtable" style="width:580px;">

			<tbody>

				<tr>

					<td class="tlabel">机构名称</td>
					<td>
						<input type="text" class="forminput inputstyle1" id="name" value="{$info.name}">
					</td>
					<td class="tlabel">省</td>
					<td>
							{if condition="$info.id neq 0"}
									{$info.province}

							{else /}
							<select type="text" id="province" class="select" v-model="checked" @change="change">
									<option value="">请选择</option>
									<option v-for="item in list" :value='item.value'>{{item.text}}</option>
								</select>
							{/if}


					
					</td>

				</tr>
				<tr>

					<td class="tlabel">市</td>
					<td>
							{if condition="$info.id neq 0"}
									{$info.city}

							{else /}
							<select type="text" id="city" class="select" v-model="checked" @change="change">
									<option value="">请选择</option>
									<option v-for="item in list" :value='item.value'>{{item.text}}</option>
								</select>
							{/if}

					
					</td>
					<td class="tlabel">县</td>
					<td>
							{if condition="$info.id neq 0"}
							{$info.area}

					{else /}
					<select type="text" id="area" class="select" v-model="checked">
							<option value="">请选择</option>
							<option v-for="item in list" :value='item.value'>{{item.text}}</option>
						</select>
					{/if}
					
					</td>

				</tr>
				<tr>


					<td class="tlabel">联系人</td>
					<td>
						<input type="text" class="forminput inputstyle1" id="truename" value="{$info.truename}">
					</td>
					<td class="tlabel">联系电话</td>
					<td>
						<input type="text" class="forminput inputstyle1" id="phone" value="{$info.phone}">
					</td>
				</tr>

				<tr>

					<td class="tlabel">开通方式</td>
					<td>
						<select type="text" id="opentype" class="select" v-model="checked" @change="change">
							<option value="">
								请选择
							</option>
							<option v-for="item in list" :value='item.value'>
								{{item.value}}
							</option>
						</select>
						
						
						<select type="text" id="daili" class="select" v-model="checked" style="<?php if($info['dailiid']!=0){ echo 'display:initial';}else{ echo 'display:none';} ?>">
							<option value="0">请选择</option>
							<option v-for="item in list" :value='item.id'>
								{{item.name}}
							</option>
						</select>
					</td>
					<td class="tlabel">机构类型</td>
					<td>
						<select type="text" id="mtype" class="select" v-model="checked">
							<option value="">
								请选择
							</option>
							<option v-for="item in list" :value='item.value'>
								{{item.value}}
							</option>
						</select>


					</td>
				</tr>


				<tr>


					<td class="tlabel">到期时间</td>
					<td colspan="3">
							<input type="text" id="endtime" autocomplete="off" class="forminput inputstyle1" onfocus="WdatePicker()" value="{$info.endtime}">
					</td>
					
				</tr>



				<tr>



					<td class="tlabel">地址</td>
					<td ><input type="text" id="address" class="forminput inputstyle1" value="{$info.address}"></td>
					<td class="tlabel">视频服务器IP</td>
					<td ><input type="text" id="ip" class="forminput inputstyle1" value="{$info.ip}"></td>
				
				</tr>




				<tr>
					<td class="tlabel">简介</td>
					<td colspan="3">
						<textarea name="desc" style="width:100%;height:100%;visibility:hidden;">{$info.desc}</textarea>
					</td>
				</tr>







			</tbody>

		</table>

		<div class="formbtn">
			<input type="button" value="保存" class="btnsave">
			<input type="button" value="取消" class="btncancel">
		</div>
		<input type="hidden" id="id" value="{$info.id}" />
	</form>


</body>
<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/vue2.js"></script>
<script src="/static/js/layer/layer.js"></script>
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="/static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/static/js/city.data-3.js"></script>
<script charset="utf-8" src="/static/My97DatePicker/WdatePicker.js"></script>

<script>
	var editor;

	$(function () {

		KindEditor.ready(function (K) {
			editor = K.create('textarea[name="desc"]', {
				resizeType: 1,
				allowPreviewEmoticons: false,
				allowImageUpload: false,
				items: [
					'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
					'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
					'insertunorderedlist', '|', 'emoticons', 'image', 'link']
			});
		});


	});

	var mtype = "{$info.mtype}";
	var opentype = "{$info.opentype}";
	var vue = new Vue({
		el: '#mtype',
		data: {
			checked: mtype,
			list: [],
		},
		methods: {

			getdata: function () {
				var _self = this;//保存this的指向
				$.post('/super/Index/getdiclist', { "name": "机构类型" }, function (data) {
					console.log(data);
					_self.list = data;
				});
			}

		},
		created: function () {  //初始化事件里边去调用查询方法
			this.getdata();
		}
	});
	var vue = new Vue({
		el: '#daili',
		data: {
			checked: "{$info.dailiid}",
			list: [],
		},
		methods: {

			getdata: function () {
				var _self = this;//保存this的指向
				$.post('/super/mechanism/GetDailiList', {  }, function (data) {
					console.log(data);
					_self.list = data;
				});
			}

		},
		created: function () {  //初始化事件里边去调用查询方法
			this.getdata();
		}
	});
	var vue = new Vue({
		el: '#opentype',
		data: {
			checked: opentype,
			list: []
		},
		methods: {
			//
			change: function () {
				if(this.checked=="代理商代理客户"){
					$("#daili").show();
				}else{
					$("#daili").hide();
					$("#daili").val(0);
				}
				
			},
			getdata: function () {
				var _self = this;//保存this的指向
				$.post('/super/Index/getdiclist', { "name": "开通方式" }, function (data) {
					console.log(data);
					_self.list = data;
				});
			}

		},
		created: function () {  //初始化事件里边去调用查询方法


			this.getdata();
		}
	});
	var province = new Vue({
		el: '#province',
		data: {
			list: [],
			checked: "{$info.province}",

		},
		methods: {
			change: function () {

				city.$data.list = getchildren(cityData3, this.checked);
				city.$data.checked = "";
			},
			getdata: function () {
				this.$data.list = cityData3;
			}

		},
		created: function () {  //初始化事件里边去调用查询方法

			this.getdata();
		}
	});
	var city = new Vue({
		el: '#city',
		data: {
			list: [],
			checked: "{$info.city}",

		},
		methods: {
			change: function () {
				area.$data.list = getchildren(this.list, this.checked);
				area.$data.checked = "";
			},
			getdata: function () {

			}

		},
		created: function () {  //初始化事件里边去调用查询方法


			this.getdata();
		}
	});
	var area = new Vue({
		el: '#area',
		data: {
			list: [],
			checked: "{$info.area}",

		},
		methods: {
			province: function () {

			},
			getdata: function () {

			}

		},
		created: function () {  //初始化事件里边去调用查询方法


			this.getdata();
		}
	});
	function getchildren(arr, text) {
		var items = [];
		for (var i = 0; i < arr.length; i++) {
			if (arr[i].value == text) {
				items = arr[i].children;
				break;

			}
		}
		return items;
	}
	$(function () {
		$(".btnsave").click(function () {
			editor.sync();
			var id = $("#id").val();

			var name = $("#name").val();
			var truename = $("#truename").val();
			var phone = $("#phone").val();
			var opentype = $("#opentype").val();
			var desc = $("#desc").val();
			var jointime = $("#jointime").val();
			var endtime = $("#endtime").val();
			var mtype = $("#mtype").val();
			var address = $("#address").val();
		
			var province = $("#province").find("option:selected").text();
			var city = $("#city").find("option:selected").text();
			var area = $("#area").find("option:selected").text();
			var number = $("#area").val();
			var dailiid = $("#daili").val();
			var ip =$("#ip").val();




			$.post("/super/Mechanism/Add", {
				"id": id, "number": number, "name": name, "truename": truename,
				"phone": phone, "opentype": opentype, "desc": desc, "jointime": jointime, "endtime": endtime, "mtype": mtype, "address": address, "state": 1,
				"province": province, "city": city, "area": area,"dailiid":dailiid,"ip":ip
			}, function (data) {
				if (data.status == 200) {
					var index = parent.layer.getFrameIndex(window.name);
					window.parent.iframe.contentWindow.location.reload(true);
					console.log(window.parent.iframe);
					parent.layer.close(index);
				} else {
					layer.msg(data.message);
				}
			});
		});
		$(".btncancel").click(function () {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
	});


</script>

</html>